package com.charles.seckillapi.feignFallBack;

import com.charles.seckillapi.feignService.RemoteLogService;
import com.charles.seckillapi.model.UserLogin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author Charles-H
 * 
 * 负载均衡日志服务降级处理
 */
@Component
public class RemoteLogServiceFallbackFactory implements FallbackFactory<RemoteLogService> {

    private static final Logger LOGGER = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
    
    @Override
    public RemoteLogService create(Throwable cause) {
        LOGGER.error("客户服务调用失败:{}", cause.getMessage());

        return new RemoteLogService() {
            @Override
            public void loginRecord(UserLogin user, String source) {
            }

            @Override
            public void logoutRecord(UserLogin user, String source) {
            }
        };
    }
}
